<template>
  <el-dialog title="下场记录" :visible.sync="showXcLog" @close="close" width="70%"  append-to-body>
    <!-- 查询条件 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.1">
        <el-input v-model="queryParams.xcfzrname" placeholder="请输入下场负责人"></el-input>
      </el-col>
      <el-col :span="1.5">
        <el-input v-model="queryParams.xcrname" placeholder="请输入下场人员"></el-input>
      </el-col>
      <el-col :span="1.5">
        <el-select v-model="queryParams.xclx" style="width: 100%;" placeholder="请选择下场类型">
          <el-option
            v-for="item in xclxList"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue">
          </el-option>
        </el-select>
      </el-col>
      <el-col :span="1.5">
        <el-input v-model="queryParams.xcbz" placeholder="请输入备注"></el-input>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-date-picker type="datetime"  value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择下场时间" v-model="queryParams.xcsj" style="width: 100%;"></el-date-picker>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button @click="resetData">重置</el-button>
        <el-button type="primary" @click="init">查询</el-button>
      </el-col>
    </el-row>
    <!-- 列表 -->
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="xcfzrname"
        label="下场负责人">
      </el-table-column>
      <el-table-column
        prop="xclx"
        label="下场类型">
        <template slot-scope="scope">
          <span v-if="scope.row.xclx === '10'">正常</span>
          <span v-if="scope.row.xclx === '20'">检补</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="xcrname"
        label="下场人员">
      </el-table-column>
      <el-table-column
        prop="xcbz"
        label="备注">
      </el-table-column>
      <el-table-column
        prop="xcsj"
        label="下场时间">
      </el-table-column>
      <el-table-column
        prop="createtime"
        label="日志记录时间">
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="init"
    />
  </el-dialog>
</template>

<script>
import { listXcapLog } from '@/api/gd/xclog'
export default {
  name: 'XcLogList',
  props: {
    showXcLog: {
      type: Boolean,
      default: false
    },
    logData: {
      type: Object
    }
  },
  data() {
    return {
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 12,
        xcid: this.logData.id,
        xcfzrname: '',
        xcrname: '',
        xcbz: '',
        xcsj: '',
        xclx: ''
      },
      tableData: [],
      xclxList: []
    }
  },
  created() {
    this.init()
    this.getDicts("gd_xclx").then(res => {
      this.xclxList = res.data
    })
  },
  methods: {
    init() {
      listXcapLog(this.queryParams).then(res => {
          if(res.code === 200) {
            this.tableData = res.rows
          }
      }).catch(err => {this.$message.error(err.ms)})
    },
    resetData() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 12,
        xcid: this.logData.id,
        xcfzrname: '',
        xcryname: '',
        xcbz: '',
        xcsj: '',
        xclx: ''
      }
      this.init()
    },
    close() {
      this.$emit("closeXcLog")
    }
  }
}
</script>

<style scoped>

</style>
